package com.xyh.service.impl;

import com.xyh.bean.Insect;
import com.xyh.dao.IInsectDao;
import com.xyh.dao.impl.InsectDaoImpl;
import com.xyh.service.IInsectService;
import com.xyh.util.PageUtil;

import java.util.List;

/**
 * @Author: XiongYuhao
 * @Date: 2020/10/23 0023-上午 10:43
 * @Description: MyForestManagerSystem
 * @version：1.0
 */
public class InsectServiceImpl implements IInsectService {
    IInsectDao iid = new InsectDaoImpl();
    @Override
    public PageUtil<Insect> listsByPage(int pageNo, int pageSize,String insectName,String host) {
        int counts = iid.insectCounts(insectName,host);
        List<Insect> insects = iid.listsByPage(pageNo, pageSize,insectName,host);
        PageUtil<Insect> pageBean = new PageUtil<>(insects,pageNo,pageSize,counts);
        return pageBean;
    }

    @Override
    public boolean addInsect(Insect insect) {
        return iid.addInsect(insect)>0?true:false;
    }

    @Override
    public boolean delete(int id) {
        return iid.delete(id)>0?true:false;
    }

    @Override
    public boolean update(Insect insect) {
        return iid.update(insect)>0?true:false;
    }
}
